﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;

namespace ChipSharp
{
    public abstract class CharpThread
    {
        Thread myThread = null;

        public CharpThread()
        {
            myThread = new Thread(new ThreadStart(Run));
        }

        ~CharpThread()
        {
            myThread.Abort();
        }

        public CharpThread(bool bAutoStart)
        {
            myThread = new Thread(new ThreadStart(Run));
            if (bAutoStart)
            {
                Start();
            }
        }

        public virtual void Start()
        {
            myThread.Start();
        }

        public virtual void Join()
        {
            myThread.Join();
        }

        public virtual void Abort()
        {
            myThread.Abort();
        }

        protected abstract void Run();
    }

}
